

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="../css/stylesite.css" medial="all" />
<link rel="stylesheet" type="text/css" href="../css/styleleft.css" medial="all" />
<link rel="stylesheet" type="text/css" href="../css/style.css" medial="all" />

	<script src="../js/jquery-1.8.2.min.js" ></script>
	<script src="js/image.js" type="text/javascript"></script>
	<script type="text/javascript">
	$(function(){
		$(".button a").click(function(){
		$(this).parent().addClass('current');
		$(this).siblings().removeClass('current');
		});
		});
	</script>
<title>Giỏ Hàng</title>
</head>

<body class="pagebody">
	<div id="wrapwebsite" >
				<?php 
			include('../element/header.php');?>
			<?php

			if(isset($_POST['update']))
			{
			foreach($_POST['qty'] as $key=>$value)
				{
					if( ($value == 0) and (is_numeric($value)))
					{
						unset ($_SESSION['cart'][$key]);
					}
					elseif(($value > 0) and (is_numeric($value)))
					{
						$_SESSION['cart'][$key]=$value;
					}
				}
			
			 header("location:../ShoppingCart/Cart.php");
			}
			?>
			<div class="imagestop"></div>
			<div class="wrapmaincontent">
		<?php
		include('../element/leftside.php');
		?>
		<div class="center-leftmargin">
		<div class="cart-show">
		<div class="moduletitle"><h2>Chi Tiết giỏ hàng </h2></div>
		<div class="modulecontent">
		<?php include_once '../Utilities/connect.php';
		mysql_set_charset('utf8',getConnect());
		
		 ?>
		 <div class="listuser">
			
			<div class="row">
			<div class="tstt" >STT</div>
			<div class="tname" >Tên sản phẩm</div>
			<div class="tsl" >Số lượng</div>
			<div class="tdongia" >Đơn Giá (VND) </div>
			<div class="ttt" >Tổng Tiền (VND)</div>
			<div class="tstt" >Delete</div>
			</div>
			<form action="Cart.php?" method="post">
			<?php
			$arr=array();
			$total=0;
			if(isset($_SESSION['cart'])&& count($_SESSION['cart'])>0)
			{
				foreach($_SESSION['cart'] as $key=>$value)
					{
					 $item[]=$key;
 					}
			$str=implode(",",$item);
			$sql="select * from product where ProductID in ($str) order by ProductID desc";
			$rl= mysql_query($sql, getConnect());
			
			while ($pr = mysql_fetch_array($rl))
				{
					$arr[]=$pr;
				}
				
			$stt=1;
			$total=0;
			foreach ($arr as $items)
			{
			$dis=$items[9];
						   $tk=$items[4]*$dis/100;
						   $pri=$items[4]-$tk;
			 ?>
			 <div class="row">
				<div class="stt" ><?php echo $stt; ?></div>
				<div class="name" ><?php echo $items[1]; ?></div>
				<div class="sl" > <input type='text' name='qty[<?php echo $items[0];?>]' size='5' value='<?php echo $_SESSION['cart'][$items[0]];?>' /> </div>
				<div class="dongia" ><?php echo $pri; ?></div>
				<div class="tt" ><?php echo $_SESSION['cart'][$items[0]] * $pri; ?></div>
				<div class="stt" ><a href="Cart_Controller.php?act=delete&prid=<?php echo $items[0];?>"><img src="../images/1318498996_DeleteRed.ico" style="cursor:pointer" width="20px" height="17px"/></a></div></div>
			 <?php $stt++;
			 $total+=$_SESSION['cart'][$items[0]]* $pri;
			 }}?>
			 <div class="row-final">
			<!-- <a href="Cart_Controller.php?act=update">Cập Nhật Giỏ Hàng</a>-->
			<input type="submit" value="Cập Nhật Giỏ Hàng" name="update"/>
			 <span>Tổng Cộng: <?php echo $total; ?>&nbsp;VND</span>
			 </div>
			 <div class="row-tt">
			 <p>
			 <a href="../Product/product.php"><img class="img1" src="../images/img_mh.png"/></a>
			  <a href="Payment.php"><img class="img2" src="../images/img_thanhtoan.png"/></a>
			 </p>
			 </div>
			 </div>
		</div>
		</div>
                   
		</div>
		</div> 
		
		<?php include('../element/footer.php'); ?>
</div>
</body>
</html>
